<?php
class Decorator		//	interface Decorate
{
	private $what;	//	$decorable;
	private $decorator;
	function __construct( & $what=null)
	{
		if (is_object($what))
			$this->what = & $what;
	}
	function set( & $what )
	{
		if (is_object($what))
			$this->what = & $what;
	}
	function decorate( & $decorator)
	{
		$this->decorator = & $decorator;
	}
	function __set($name,$value)
	{}

	function __call($method,$args)
	{
		if (is_callable(array($this->decorator,$method)))
			return call_user_func_array(array($this->decorator,$method),$args);
		if (is_callable(array($this->$what,$method)))
			return call_user_func_array(array($this->what,$method),$args);

		trigger_error('Ботва какая-то');
		return null;
	}
}
?>